<?php
namespace app\common\model;

use think\Model;

class ConfigModel extends Model
{
    public $config_path = '';//配置文件地址
    public $write = true;//是否允许写入

    /**
     * @name: 服务器运行状态
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-10-23 13:47:14
     */
    public function serverRunningStatus ()
    {
        $this->config_path = '../runtime/config/server_pcinfo.json';
        $this->write = false;
        return [];
    }

    /**
     * @name: mycat 更新
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-10-23 16:06:30
     */
    public function mycatNodeUpdate ()
    {
        $this->config_path = './Db/mycat_update.lock';
        $this->write = false;
        return [];
    }

    /**
     * @name: 检测是否已经安装
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-10-24 10:30:10
     */
    public function checkInstall ()
    {
         $this->config_path = './.install.lock';//安装文件
         $this->write = false;
         return [];
    }

    /**
     * @name: 页面信息提示设置 TODO
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-10-24 10:37:56
     */
    public function webPageAlertsManage ()
    {
        $this->config_path = '../runtime/config/webPageAlertsManage.conf';//其他配置文件
        return [
            '资产管理' => 'assets',//资产管理
            '主机安全管理' => 'hostservice',//主机安全管理
            '日志管理' => 'log',//日志管理
            '平台管理' => 'system',//平台管理
            '其他工具' => 'othertool',//其他工具
        ];
    }

    /**
     * @name: 授权信息
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-10-24 14:49:02
     */
    public function authorizationInformation ()
    {
        $this->write = false;
        $this->config_path = '../runtime/config/authInfo.json';//授权信息文件
        return [];
    }

    /**
     * @name ip白名单设置
     * @return array
     * @author wx
     * @date time
     */
    public function ipWhiteSetting()
    {
        $this->write = true;
        $this->config_path = '../runtime/config/allow_ip.conf';

        return [
            '工作生效期' => 'time_range',//功能生效期 0->永久 1->30 2->1H 3->8H 4->16H
            '工作模式' => 'status',//开启状态
        ];
    }

    /**
     * @name syslog配置
     * @return array
     * @author wx
     * @date 2019/10/29 14:17
     */
    public function syslog()
    {
        $this->write = true;
        $this->config_path = '../runtime/config/syslog.conf';

        return [
            '协议' => 'protocol',//协议
            'IP地址' => 'host',//主机地址
            '端口号' => 'port',//端口
            '状态' => 'status',//开关状态
        ];
    }

    /**
     * @name elk配置
     * @return array
     * @author wx
     * @date 2019/10/29 14:32
     */
    public function elk ()
    {
        $this->write = true;
        $this->config_path = '../runtime/config/elk.conf';

        return [
            '地址和端口' => 'hosts',//地址和端口
            '用户名' => 'user',//用户名
            '密码' => 'password',//密码
            '数据库名' => 'index',//数据库名
            '状态' => 'status'//状态
        ];
    }

    public function login()
    {
        $this->write = true;
        $this->config_path = '../runtime/config/login.conf';

        return [
           '限制次数' => 'fail_count',//失败次数
           '限制时间' =>'fail_time',//失败次数之后的时间
        ];
    }
}